functor CodeGenMain (S : CODEGEN_MAIN_STRUCTS) : CODEGEN_MAIN =
struct
  open S

  structure F = Frame (structure Ir = Ir
                       structure Assem = Assem)
  structure C = Codegen (structure Frame = F)

  structure P = Prfgen (structure Frame = F)

  structure T = Temp
 
  fun ir2code ir = 
      let val _ = T.resetLabel ()
      in  C.ir2code ir
      end
  fun ir2pprf ir = 
      let val _ = T.resetLabel ()
      in  C.ir2pprf ir
      end
  fun rebdChs ((frlist, data), file') = 
      let val ninf = C.rebdChs (frlist, data)
          val filename' = File.nameToString file'
	  val filename = String.substring (filename', 0, String.size (filename')-2)
      in P.outChs ninf filename
      end
  fun ir2prf ir = 
      let val _ = T.resetLabel ()
          val (framelist, data) = C.ir2framel ir
      in  P.top (framelist, data)
      end
end 
